-
Notifications
You must be signed in to change notification settings - Fork 4.2k
[export] backed_size_oblivious tutorial #3400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/tutorials/3400
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 5b1689e with merge base ab2aafd ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
@@ -591,6 +592,30 @@ def forward(self, x, y): | |||
"bool_val": None, | |||
} | |||
|
|||
###################################################################### | |||
# (experimental) Avoiding 0/1 specialization |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be added after the section on 0/1 specialization? or move the section on 0/1 specialization to right before here?
# (experimental) Avoiding 0/1 specialization | ||
# ^^^^^^^^^^^^^^^^^^ | ||
# | ||
# Export provides an experimental option to avoid specializing on size 0/1 sample inputs. Users can turn on `torch.fx.experimental._config.backed_size_oblivious = True` to enable this behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Export provides an experimental option to avoid specializing on size 0/1 sample inputs. Users can turn on `torch.fx.experimental._config.backed_size_oblivious = True` to enable this behavior. | |
# Export provides an experimental option to avoid specializing on size 0/1 sample inputs. Users can turn on ``torch.fx.experimental._config.backed_size_oblivious = True`` to enable this behavior. |
y = torch.randn(1) | ||
dynamic_shapes = {"x": (Dim.AUTO, Dim.AUTO), "y": (Dim.AUTO,)} | ||
with torch.fx.experimental._config.patch(backed_size_oblivious=True): | ||
ep = export(Foo(), (x, y), dynamic_shapes=dynamic_shapes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print ep?
ep = export(Foo(), (x, y), dynamic_shapes=dynamic_shapes) | ||
ep.module()(torch.randn(8, 1), torch.randn(1)) | ||
ep.module()(torch.randn(5, 6), torch.randn(6)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wonder if it would be good to add an example where the behavior is weir after setting backed_size_oblivious. your example here is a little simple.
Fixes #ISSUE_NUMBER
Description
Adds an export tutorial section for avoiding 0/1 specialization
Checklist
cc @avikchaudhuri @gmagogsfm @zhxchen17 @tugsbayasgalan @angelayi @suo @ydwu4